import Vue from 'vue'
import VueRouter from 'vue-router'
import Logon from '../views/Logon.vue'
import LayoutView from '../views/Layout/layout.vue'
import HomeIndex from '@/views/home/index.vue'
import GoodCar from '@/views/good/index.vue'
import XtxCartPage from '@/views/User/index.vue'
import GoShopping from '@/views/shopping/index.vue'
import OfferForSale from '@/views/offerforsale/index.vue'
import UserSale from '@/views/usersale/index.vue'
import EditorCar from '@/views/editorcar/EditorCar.vue'
Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'HomeView',
    component: Logon
  },
  
  {
    path: '/',
    name: 'LayoutView',
    component: LayoutView,
    children: [
      {
        path: '', // 路由置空的时候会作为一级路由默认渲染的二级路由
        component: HomeIndex
      },
      {
        path: '/goods',
        component: GoodCar
      },
      {
        path: '/user',
        component: XtxCartPage
      },
      {
        path: '/shopping',
        component: GoShopping
      },
      {
        path: '/offerforsale',
        component: OfferForSale
      },
      {
        path: '/usersale',
        name: 'usersale',
        component: UserSale
      },
      {
        path: '/editorcar',
        name: 'editorcar',
        component: EditorCar
      },
      {
        path: '/search/:id',
        component: () => import('@/views/search/search.vue')
      },
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
